package pens.penObjects
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import pens.PenType;
	import pens.interfaces.IPenPlayer;
	/**
	 * 鼠标钢笔 
	 * @author Administrator
	 * 
	 */	
	public class Pen_Sign_Mouse extends Pen_Sign implements IPenPlayer
	{
		private static var instance:Pen_Sign_Mouse;
		/**
		 *单例模式
		 *
		 **/
		public static function getInstance():Pen_Sign_Mouse{
			if(!instance) instance=new Pen_Sign_Mouse();
			return instance;
		}
		/***************************************************/
		
		
		
		private var nowSize:Number=10;
		private var oldX:Number;
		private var oldY:Number;
		
		private var _isDown:Boolean=false
		public function Pen_Sign_Mouse()
		{
			super();
			_penName=PenType.PEN_SIGN_MOUSE
			if (stage) inits();
			else addEventListener(Event.ADDED_TO_STAGE, inits);
		}
		private function inits(e:Event=null):void{
			removeEventListener(Event.ADDED_TO_STAGE, inits);
			addEventListener(MouseEvent.MOUSE_DOWN,ondownHand,false,0,true)
			stage.addEventListener(MouseEvent.MOUSE_UP,onupHand,false,0,true);
			addEventListener(MouseEvent.MOUSE_MOVE,onmoveHand)    
		}
		
		private function ondownHand(e:MouseEvent):void{
			
				_isDown=true
				nowSize=PenType.penSize
				moveTo(mouseX,mouseY,nowSize,PenType.penColor)	
				lineTo(mouseX,mouseY,nowSize,PenType.penColor)
		}
		private function onupHand(e:MouseEvent):void{
			_isDown=false
		}
		private function onmoveHand(e:MouseEvent):void{
			if(!_isDown)return
			lineTo(mouseX,mouseY,nowSize,PenType.penColor)
				
			}	
	}
}